package org.eden.karb.configuration.impl;

import org.eden.karb.common.util.TypeConversionUtils;
import org.eden.karb.configuration.Configuration;
import org.eden.karb.configuration.ConfigurationService;

import java.util.Properties;

/**
 * {@inheritDoc}
 */
public class ConfigurationServiceImpl implements ConfigurationService {
    
    private Properties properties;

    /**
     * {@inheritDoc}
     */
    public <T> T get(Configuration key, Class<T> clazz) {
        String configurationValue = this.properties.getProperty(key.getValue());
        return TypeConversionUtils.convert(configurationValue, clazz);
    }

    public Properties getProperties() {
        return properties;
    }

    public void setProperties(Properties properties) {
        this.properties = properties;
    }
}
